#include <iostream>
#include <vector>
#include <map>
#define all(e) e.begin(), e.end()
#define int long long
using namespace std;

signed main()
{
	int t; cin >> t;
	while (t--)
	{
		int n, m; cin >> n >> m;
		map<int, int> cnt;
		vector<map<int, int>> arr;
		for (int i = 0; i < n; ++i)
		{
			int l; cin >> l;
			arr.push_back({});
			while (l--)
			{
				int tmp; cin >> tmp;
				arr.back()[tmp]++;
				cnt[tmp]++;
			}
		}
		bool jug = true;
		for (int i = 1; i <= m; ++i) if (cnt.count(i) == 0) { jug = false; break; }
		if (jug == false) { cout << "NO" << endl; continue; }
		int ans = 1;
		for (auto& r : arr)
		{
			jug = true;
			for (auto& c : r) if (cnt[c.first] == c.second) { jug = false; break; }
			if (jug) ans++;
			if (ans >= 3) break;
		}
		if (ans >= 3) cout << "YES" << endl;
		else  cout << "NO" << endl;
	}
	return 0;
}